package com.hs.jhzd.repository;

import com.hs.jhzd.entity.ZfSgdpbxxbEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface ZfSgdpbxxbRepository extends JpaRepository<ZfSgdpbxxbEntity, String> {

    @Query("select y from ZfSgdpbxxbEntity y where   (y.rq BETWEEN :startTime and :endTime) and y.scbj = false and" +
            " y.jsbh=:jsbh and" +
            " y.jsh=:jsh")
    public List<ZfSgdpbxxbEntity> findShiftByRq(@Param("jsbh") String jsbh, @Param("jsh") String jsh, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

//    @Query("select y from ZfSgdpbxxbEntity y where y.scbj = false and" +
//            " y.jsbh=:jsbh and" +
//            " y.jsh=:jsh and " +
//            " y.xq=:xq " )
//    public List<ZfSgdpbxxbEntity> findFirstByJsbhByJshByXq(@Param("jsbh") String jsbh, @Param("jsh") String jsh, @Param("xq") String xq);

    List<ZfSgdpbxxbEntity> findByJsbhAndJshAndXqOrderByRqDesc(@Param("jsbh") String jsbh, @Param("jsh") String jsh,
                                         @Param("xq") String xq);

    @Query("select y from ZfSgdpbxxbEntity y where   (y.rq BETWEEN :startTime and :endTime) and y.scbj = false and" +
            " y.jsbh=:jsbh and" +
            " y.jsh=:jsh")
    public List<ZfSgdpbxxbEntity> findByJsbhAndJshByRq(@Param("jsbh") String jsbh, @Param("jsh") String jsh, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

}
